#ifndef PHP_EVENTDISPATCHER_H
#define PHP_EVENTDISPATCHER_H

extern zend_module_entry EventDispatcher_module_entry;
#define phpext_EventDispatcher_ptr &EventDispatcher_module_entry

#ifdef PHP_WIN32
#	define PHP_EVENTDISPATCHER_API __declspec(dllexport)
#elif defined(__GNUC__) && __GNUC__ >= 4
#	define PHP_EVENTDISPATCHER_API __attribute__ ((visibility("default")))
#else
#	define PHP_EVENTDISPATCHER_API
#endif

#ifdef ZTS
#include "TSRM.h"
#endif

PHP_MINIT_FUNCTION(EventDispatcher);
PHP_MSHUTDOWN_FUNCTION(EventDispatcher);
PHP_RINIT_FUNCTION(EventDispatcher);
PHP_RSHUTDOWN_FUNCTION(EventDispatcher);
PHP_MINFO_FUNCTION(EventDispatcher);

PHP_METHOD(EventDispatcher, __construct);
PHP_METHOD(EventDispatcher, addEventListener);
PHP_METHOD(EventDispatcher, hasEventListener);
PHP_METHOD(EventDispatcher, removeEventListener);
PHP_METHOD(EventDispatcher, dispatchEvent);

/*
ZEND_BEGIN_MODULE_GLOBALS(EventDispatcher)

ZEND_END_MODULE_GLOBALS(EventDispatcher)
*/
/* 
   In every utility function you add that needs to use variables 
   in php_EventDispatcher_globals, call TSRMLS_FETCH(); after declaring other 
   variables used by that function, or better yet, pass in TSRMLS_CC
   after the last function argument and declare your utility function
   with TSRMLS_DC after the last declared argument.  Always refer to
   the globals in your function as EVENTDISPATCHER_G(variable).  You are 
   encouraged to rename these macros something shorter, see
   examples in any other php module directory.
*/
typedef struct _php_event_dispatcher_obj php_event_dispatcher_obj;

struct _php_event_dispatcher_obj {
	zend_object       std;
	HashTable        *event_listeners;
};

#ifdef ZTS
#define EVENTDISPATCHER_G(v) TSRMG(EventDispatcher_globals_id, zend_EventDispatcher_globals *, v)
#else
#define EVENTDISPATCHER_G(v) (EventDispatcher_globals.v)
#endif

#endif	/* PHP_EVENTDISPATCHER_H */
